package cn.jinjimi.app.poster.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;

import java.io.Serializable;

/**
 * Created by lforxeverc on 16/9/22.
 */

public class PosterInfo implements Parcelable {
    //小图
    @SerializedName("icon_url")
    public String thumbnailUrl;
    //模版id
    @SerializedName("id")
    public int templateId;
    //模版布局
    @SerializedName("layout")
    public String layout;
    //分享次数
    @SerializedName("share_count")
    public int shareCounts = -1;
    //模版名称
    @SerializedName("title")
    public String title;

    public String productId;


    //v2.9.0修改海报实现，加载水印url和背景url后手动合成
    @SerializedName("poster_detail")
    public PosterDetailInfo posterDetailInfo;

    public PosterInfo(String thumbnailUrl, int templateId) {
        this.thumbnailUrl = thumbnailUrl;
        this.templateId = templateId;
    }

    protected PosterInfo(Parcel in) {
        thumbnailUrl = in.readString();
        templateId = in.readInt();
        layout = in.readString();
        shareCounts = in.readInt();
        title = in.readString();
        productId = in.readString();
        Serializable s = in.readSerializable();
        if (s instanceof PosterDetailInfo)
            posterDetailInfo = (PosterDetailInfo) s;
    }


    public static final Creator<PosterInfo> CREATOR = new Creator<PosterInfo>() {
        @Override
        public PosterInfo createFromParcel(Parcel in) {
            return new PosterInfo(in);
        }

        @Override
        public PosterInfo[] newArray(int size) {
            return new PosterInfo[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(thumbnailUrl);
        dest.writeInt(templateId);
        dest.writeString(layout);
        dest.writeInt(shareCounts);
        dest.writeString(title);
        dest.writeString(productId);
        dest.writeSerializable(posterDetailInfo);
    }
}
